package cameragps;

import net.rim.device.api.util.Persistable;

/**
 * This class is used to store information which is yet to be sent it is used to
 * store information in PersistentStore
 * 
 * @see ImageUtils#sendAfterwards
 * 
 */
public class ImageInformation implements Persistable {

	static int IMAGENAME = 0;
	static int USERTEXT = 1;
	static int LATITUDE = 2;
	static int LONGITUDE = 3;
	static int LOCATION = 4;

	private String[] fields;

	private boolean isSent = true;
	
	public ImageInformation(String[] fields,boolean isSent) throws Exception {
		super();
		if (fields.length == 5){
			this.fields = fields;
			this.isSent = isSent;
		}else{
			throw new Exception();
		}
	}

	public String[] getFields() {
		return fields;
	}

	public String getField(int fieldIndex) {
		if (fieldIndex <= 4 && fieldIndex >= 0)
			return fields[fieldIndex];
		else
			return null;
	}

	public void markAsSent(){
		isSent = true;
	}

	public boolean isSent() {
		return isSent;
	}

	
	public void showData() {

		try {

			System.out.println(".---------------------------.");
			System.out.println("IMAGENAME: " + fields[IMAGENAME]);
			System.out.println("USERTEXT : " + fields[USERTEXT ]);
			System.out.println("LATITUDE : " + fields[LATITUDE ]);
			System.out.println("LONGITUDE: " + fields[LONGITUDE]);
			System.out.println("LOCATION : " + fields[LOCATION ]);
			
			System.out.println("\nISSENT : " + isSent);
			
			System.out.println("'---------------------------'");

		} catch (Exception e) {
			e.printStackTrace();

		}

	}

}